package com.jims.master.modules.base.netHosptial.service;


import com.jims.master.common.persistence.Page;
import com.jims.master.common.service.CrudService;
import com.jims.master.common.utils.PinyinUtils;
import com.jims.master.modules.base.netHosptial.dao.NetDataIcd10Dao;
import com.jims.master.modules.base.netHosptial.entity.NetDataIcd10;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by zhao on 2015/10/15.
 * 病种ICD10Service
 */
@Service
@Transactional(readOnly = true)
public class NetDataIcd10Service extends CrudService<NetDataIcd10Dao,NetDataIcd10> {
    @Autowired
    private NetDataIcd10Dao netDataIcd10Dao;


    /**
     * 保存
     * @param emrDataIcd10
     */
    @Transactional(readOnly = false)
    public void saveEmrIcd10(NetDataIcd10 emrDataIcd10) {
        //获取拼音
        emrDataIcd10.setPinyinIndex(PinyinUtils.getPinyinFirst(emrDataIcd10.getZhongwenMingcheng()).toUpperCase());
        //获取索引
        emrDataIcd10.setKeywordShuoming(emrDataIcd10.getCode()+"|"+
                emrDataIcd10.getZhongwenMingcheng()+"|"+
                emrDataIcd10.getPinyinIndex());
        //大类默认为0
//        emrDataIcd10.setPid(0);
      this.save(emrDataIcd10);

    }


    /**
     * 加载数据ICD
     * @param emrDataIcd10Page
     * @param emrDataIcd10
     * @return
     */
    public List<NetDataIcd10> findForPidList(Page<NetDataIcd10> emrDataIcd10Page ,NetDataIcd10 emrDataIcd10){
        return emrDataIcd10Page.setList( netDataIcd10Dao.findList(emrDataIcd10)).getList();
    }


    public List<NetDataIcd10> hisDataIcdName(String name){
        return dao.hisDataIcdName(name);
    }
}
